package com.yisu.auction.api.domain.response.rechargePackge;

import com.yisu.auction.ewf.entity.MobileRecharge;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by caeri on 2017/9/26.
 */
public class RechargeListResponse {
    private Integer mobileOperator;

    private Integer rechargeType;

    private String imgUrl;

    private String description;

    private String amount;

    private String time;

    private String status;

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(int mobileOperator, int rechargeType) {
        this.imgUrl = getImageUrlByCode(mobileOperator, rechargeType);
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public String getTime() {
        return time;
    }

    public void setTime(Date time) {
        if (time.getYear() == new Date().getYear()) {
            SimpleDateFormat formatter = new SimpleDateFormat("MM-dd HH:mm");
            this.time = formatter.format(time);
        } else {
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            this.time = formatter.format(time);
        }
    }

    public Integer getMobileOperator() {
        return mobileOperator;
    }

    public void setMobileOperator(Integer mobileOperator) {
        this.mobileOperator = mobileOperator;
    }

    public Integer getRechargeType() {
        return rechargeType;
    }

    public void setRechargeType(Integer rechargeType) {
        this.rechargeType = rechargeType;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = MobileRecharge.MobileRechargeStatus.getEnumNameByCode(status);
    }



    public static String getImageUrlByCode(int mobileOperator, int rechargeType) {
        if (rechargeType == MobileRecharge.RechargeTypeEnum.Traffic.code) {
            return "http://qiniu.ddbaoxiang.com/170926143833268332439755.png";
        } else {
            switch (mobileOperator) {
                case 1:
                    return "http://qiniu.ddbaoxiang.com/170926143807733618613197.png";
                case 2:
                    return "http://qiniu.ddbaoxiang.com/170926143750161998804559.png";
                case 3:
                    return "http://qiniu.ddbaoxiang.com/170926143659889321549174.png";
            }
        }
        return "";
    }
}
